package com.zidian.study.utils;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * class name : StringHelper  --String工具类
 * Created on 14/4/2016.
 * name : xjc
 */
public class StringHelper {

    /**
     * 解析网站
     * @return
     */
    public static String parseString(String datas){
        return datas.replace("\\","").replace("\"","").replace("[","").replace("]","");
    }

    /**
     *
     */
    public static String  convert(String mill){
        String strs="0";
            try {
                long l = Long.parseLong(mill);
                Date date=new Date(l);

                SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                strs=sdf.format(date);
            } catch (Exception e) {
                e.printStackTrace();
                return "0";
            }
            return strs;

        }




    /**
     * 截取字符，获取文件名称
     */
    public static String getImageName(String path){
        if (path != null){
            String str1=path.substring(path.lastIndexOf("/")+1, path.length());
            return str1;
        }else {
            return path;
        }
    }

    /**
     * 截取字符，获取文件名称
     */
    public static String getImagePath(String path){
        if(path != null){
            if (path.substring(0,1).equals("/")){
                String str0=path.substring(1, path.length()-1);
                return str0;
            }else {
                return path;
            }
        }else{
            return path;
        }
    }
}
